package com.yaoxun.console.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yaoxun.console.service.LoginService;
import com.yaoxun.console.xo.req.LoginReq;
import com.yaoxun.console.xo.resp.ApiResp;
import com.yaoxun.console.xo.resp.LoginResp;

@Controller
public class LoginController implements BaseController {

	@Autowired
	private LoginService loginService;
	
	
	@PostMapping("/login")
	@ResponseBody
	public ApiResp<LoginResp> login(@Validated @RequestBody LoginReq req, HttpServletResponse response) {
		LoginResp resp = loginService.login(req, response);
		return ofRoSuccess(resp);
	}
	
}
